﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZXIMEW.DAL;
using ZXIMEW.Models.DModels;

namespace ZXIMEW.BLL
{
    public class ModbusParaBLL
    {
        ModbusParaDAL paraDAL = new ModbusParaDAL();
        /// <summary>
        /// 获取所有的参数列表
        /// </summary>
        /// <returns></returns>
        public List<ModbusParaSetInfo> GetAllParas()
        {
            return paraDAL.GetAllParas();
        }

        /// <summary>
        /// 实时参数变量列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ModbusParaSetInfo> GetActualParaAddressList()
        {
            Dictionary<string, ModbusParaSetInfo> dicList = new Dictionary<string, ModbusParaSetInfo>();
            List<ModbusParaSetInfo> allList = GetAllParas();
            //筛选出实时参数变量
            var actualList = allList.Where(s => s.ParaName.Contains("Actual")).ToList();
            actualList.ForEach(p => dicList.Add(p.ParaName, p));
            return dicList;
        }

        /// <summary>
        /// 设置参数变量列表
        /// </summary>
        /// <returns></returns>
        public Dictionary<string, ModbusParaSetInfo> GetSetParaAddressList()
        {
            Dictionary<string, ModbusParaSetInfo> dicList = new Dictionary<string, ModbusParaSetInfo>();
            List<ModbusParaSetInfo> allList = GetAllParas();
            //筛选出设置参数变量
            var setList = allList.Where(s => !s.ParaName.Contains("Actual")).ToList();
            setList.ForEach(p => dicList.Add(p.ParaName, p));
            return dicList;
        }

        /// <summary>
        /// 报表参数列表获取
        /// </summary>
        /// <returns></returns>
        public List<ModbusParaSetInfo> GetReportParaList()
        {
            List<ModbusParaSetInfo> allList = GetAllParas();
            return allList.Where(p => p.IsReport).ToList();
        }
    }
}
